Skip to content

Comments

[SDC-29853] Fix Frameworks Code Snippets#317

Open
ilber wants to merge 19 commits intomainfrom
fix/SDC-29853-code-snippets-related-to-frameworks
Open

[SDC-29853] Fix Frameworks Code Snippets#317
ilber wants to merge 19 commits intomainfrom
fix/SDC-29853-code-snippets-related-to-frameworks

Conversation

@ilber
Copy link
Member

@ilber ilber commented Feb 24, 2026

In addition to the fixes on the code snippets for Flutter, React-Native, Cordova, Capacitor and Titanium I have also updated the DataCaptureContext initialization pattern across Flutter, Capacitor, Cordova, and React Native docs

This MR updates the documentation to reflect the new DataCaptureContext API, where initialization is done once via an async call and the context is accessed afterwards through a shared instance.

Code snippets

  • Replaced DataCaptureContext.forLicenseKey(...) with await DataCaptureContext.initialize(...) across all affected get-started and barcode-generator guides
  • Updated all subsequent references to the context variable (context, dataCaptureContext) to use DataCaptureContext.sharedInstance

export default DataCaptureContext.instance;
```
```ts
await DataCaptureContext.initialize('-- ENTER YOUR SCANDIT LICENSE KEY HERE --');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think initialize is an async function

const barcodeSelection = new Scandit.BarcodeSelection(settings);
context.addMode(barcodeSelection);
const barcodeSelection = new BarcodeSelection(settings);
DataCaptureContext.sharedInstance.addMode(barcodeSelection);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be an awaitable

Comment on lines 40 to 148
@@ -85,7 +87,7 @@ Next, create a [BarcodeSelection](https://docs.scandit.com/data-capture-sdk/cord

```js
const barcodeSelection = new Scandit.BarcodeSelection(settings);
context.addMode(barcodeSelection);
DataCaptureContext.sharedInstance.addMode(barcodeSelection);
```

## Register the Barcode Selection Listener
@@ -126,7 +128,7 @@ When using the built-in camera there are recommended settings for each capture m
recommended settings and create the camera from it:

```js
const cameraSettings = Scandit.BarcodeSelection.recommendedCameraSettings;
const cameraSettings = Scandit.BarcodeSelection.createRecommendedCameraSettings();

// Depending on the use case further camera settings adjustments can be made here.

@@ -141,7 +143,7 @@ Because the frame source is configurable, the data capture context must be told
[DataCaptureContext.setFrameSource()](https://docs.scandit.com/data-capture-sdk/cordova/core/api/data-capture-context.html#method-scandit.datacapture.core.DataCaptureContext.SetFrameSourceAsync):

```js
context.setFrameSource(camera);
DataCaptureContext.sharedInstance.setFrameSource(camera);
```

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would DataCaptureContext here need to be Scandit.DataCaptureContext?


```js
let barcodeAr;
let barcodeArView;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this variable isn't used


```js
let barcodeFind;
let barcodeFindView;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not used

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants